'''
需要创建一个动作链对象 ActionChains(driver)
perform()执行
'''

import time


from selenium import webdriver
from selenium.webdriver import ActionChains, Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait

driver = webdriver.Edge()
driver.get("http://www.baidu.com")
time.sleep(3)

# 创建动作链对象
ac = ActionChains(driver)

# 获取拖动的标签
a = driver.find_element(By.PARTIAL_LINK_TEXT,"官方")
# 获取文本编辑标签
b = driver.find_element(By.ID,"chat-textarea")

# 动作链对象进行拖动动作，并且执行
ac.drag_and_drop(a,b).perform()
# 执行回车
ac.send_keys(Keys.ENTER).perform()

time.sleep(10)